from demo.db import db_model


class CourseModel(db_model.Model):
    __tablename__ = 'course'
    id = db_model.Column(db_model.Integer, primary_key=True)  # 主键
    name = db_model.Column(db_model.String(120), unique=False, nullable=False)
    hours = db_model.Column(db_model.Integer, unique=False, nullable=False)
    def __init__(self):
        pass

    def to_dict(self):
        return {
            "id": self.id,
            "name": self.name,
            "hours": self.hours
        }
